//
//  config.swift
//  jocool
//
//  Created by tong on 16/6/11.
//  Copyright © 2016年 zhuxietong. All rights reserved.
//

import Foundation
import UIKit
import Eelay
import AdSupport

public struct MoError{
    public let message:String
}


public enum ErrorType:Error{
    case `default`(Any)
    case request(Any)
}

public enum AppEnvironment {
    case dev
    case pro
    case test
    public static var current:AppEnvironment = .dev
}

public class __app{
    
    
    
//    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
//    NSMutableString *currentVersion = [NSMutableString stringWithString:[infoDic objectForKey:@"CFBundleShortVersionString"]]
    
    public static let client_version:String = (Bundle.main.infoDictionary?.mutable_dictionary ?? NSMutableDictionary())["CFBundleShortVersionString",""]
    public static let system_verion = UIDevice.current.systemVersion
    public static let device_id = ASIdentifierManager.shared().advertisingIdentifier.uuidString
    
    public static var rootController:UIViewController? = nil
    
    
    public static var welcome_qote = "原生App开启您的Quality life"
    public static var welcome_detail_qote = "原生App为你带来Quality life"
    
    public static var owner = "XXXX公司"
    public static var name = "App"
    
    
    public enum Mode:Int{
        case simple = -1
        case normal = 1
        case douyun = 2
        case yunxue = 0
        


        
        public static var current:Mode{
            get{
                let n = UserDefaults.standard.integer(forKey: "__app.Mode")
                guard let m = Mode(rawValue: n) else { return .normal }
                return m
            }
            set{
                
                UserDefaults.standard.set(newValue.rawValue, forKey: "__app.Mode")
            }
        }
    }


    public struct technology{
        public static var net = "http://www.XXXXX.com"
        public static var tel = "0871-XXXXXXXXXXXXX"
        public static var name = "XXXX科技公司"
    }
    
    //
    //    static func chatService(serviceID:String="\(JPImKefu)",from:UIViewController)
    //    {
    //        SoNum.read_kefu("kf_id")
    //        UserControl.getUser(true) { (success, msg, user) in
    //            if let _ = user
    //            {
    //                //                SPKitExample.sharedInstance().exampleOpenConversationViewController(with: YWPerson(personId: "\(serviceID)"), from:from.navigationController!)
    //
    //            }
    //        }
    //    }
    //
    //    static func chatClent(userID:String,from:UIViewController){
    //
    //        SoNum.read_kefu("kf_id")
    //        UserControl.getUser(true) { (success, msg, user) in
    //            if let _ = user
    //            {
    //                //                SPKitExample.sharedInstance().exampleOpenConversationViewController(with: YWPerson(personId: "\(userID)"), from:from.navigationController!)
    //            }
    //        }
    //    }
    
    
    public static var serverPhone:String = ""
    public static func call(serverPhone phone:String=__app.serverPhone){
        
        //        JoAlertView(info: "提示","拨打客服电话：(\(phone))","取消").append(title: "拨打") {
        UIApplication.shared.openURL(NSURL(string: "tel://\(phone)")! as URL)
        //            }.show(at: __controller)
        
    }
}

public enum JoReg:String {
    case mobile = "^1\\d{10}$"
    case username = "^[a-zA-Z0-9_-]{4,16}$"
    case password = "^\\S{1,32}$"
    case code = "^\\S{1,100}"
    case 身份证 = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)"
    case 护照 = "^1[45][0-9]{7}|G[0-9]{8}|P[0-9]{7}|S[0-9]{7,8}|D[0-9]+$"
    case email = "^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$"
    case price = "(^[1-9]\\d*(\\.\\d{1,2})?$)|(^0(\\.\\d{1,2})?$)"
    case priceV = "(^[1-9][0-9]{0,7}$)|(^((0\\.0[1-9]$)|(^0\\.[1-9]\\d?)$)|(^[1-9][0-9]{0,7}\\.\\d{1,2})$)"
    case phone = "^1+[123456789]+\\d{9}$|(^$)|(^(0\\d{2})-(\\d{8})$)|(^(0\\d{3})-(\\d{7,8})$)|(^(0\\d{2})-(\\d{8})-(\\d+)$)|(^(0\\d{3})-(\\d{7,8})-(\\d+)$)"

    
}




